﻿@{
    Layout = null;
}
@model  xEasyApp.Core.Repositories.DictInfo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>字典管理</title>
    @Html.Css("main","form")
</head>
<body>
    <div style="padding:5px;">
       
            @using (Html.BeginForm("SaveDictInfo", "SysManage", new { id = Model.DictID }, FormMethod.Post, new { id = "fmEdit" }))
            {
        
        <div class="mainpanel">
            <table id="xeasy-form-table" width="100%" cellspacing="4"  cellpadding="1">
                <tr>
                    <td style="width:70px;">
                        <label>字典代码：</label>
                    </td>
                    <td>                      
                       
                        @if (Model.DictID == 0)
                        {                        
                            @Html.TextBox("DictCode", Model.DictCode, new { style = "width:90%;" })
                        }
                        else
                        { 
                           @Html.TextBox("DictCode", Model.DictCode, new { style = "width:90%;", ReadOnly = "ReadOnly" })
                        }                      
                        <span class="xeasy-formItemMust">*</span>
                    </td> 
                </tr>
                <tr>
                  <td style="width:70px;">
                        <label>字典名称：</label>
                  </td>
                  <td>
                        @Html.TextBox("DictName", Model.DictName, new { style = "width:90%;" })
                        <span class="xeasy-formItemMust">*</span>
                  </td>
                
                </tr>
                 <tr>
                  <td style="width:70px;">
                        <label>父角色：</label>
                  </td>
                  <td>
                        @Html.Hidden("ParentID", Model.ParentID, new { style = "width:90%;" })
                        <span id="lbParentName">
                             @Html.DisplayTextFor(x => x.ParentName) 
                        </span>
                  </td>
                
                </tr>
                 <tr>
                  <td style="width:70px;">
                        <label>字典说明：</label>
                  </td>
                  <td>
                        @Html.TextArea("Remark", Model.Remark, new { style = "width:90%;" })                       
                  </td>
                 <tr>
                  <td style="width:70px;">
                        <label>排序：</label>
                  </td>
                  <td>
                        @Html.TextBox("Sequence", Model.Sequence, new { style = "width:80px;"})
                        <span class="xeasy-formItemMust">*</span>
                  </td>           
                </tr>
            </table>
           
            </div>
            }
           
    </div>
     <div class="buttonpanel">
             <div style="float:right;margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>取消</span></a>
              </div>
              
    </div>
    @Html.Js("jquery", "common", "form","validate")
    <script type="text/javascript">
        $(document).ready(function (e) {
            $("#btnSave").click(function (e) {
                $("#fmEdit").submit();
            });
            $("#btnCancel").click(function (e) {
                CloseModelWindow(null, false);
            });
            var options = {
                beforeSubmit: function () {
                    return true;
                },
                dataType: "json",
                success: function (data) {
                    if (data.IsSuccess) {
                        CloseModalDialog(null, true);
                    }
                    else {
                        showErrorTip(data.Msg, {left:10,top:100}, true, 3000);
                    }
                }
            };
            $("#fmEdit").validate(
             {
                 submitHandler: function (form) {                    
                     $("#fmEdit").ajaxSubmit(options);
                 },
                 rules:
                 {
                     DictCode: { required: true, safe: true },
                     DictName: { required: true, safe: true },
                     Sequence:{ required: true, digits: true }
                 },
                 messages: {
                     RoleCode: { required: "角色代码不能为空",},
                     RoleName: { required: "角色名称不能为空" },
                     Sequence:{ required: "排序号不能为空", digits: "排序号必须是个数字" }
                 },
                 errorElement: "div",
			     errorClass: "cusErrorPanel",
			     errorPlacement:showValidateError
            });
            $.validator.addMethod("safe", function (value, element) {
                return this.optional(element) || /^[^$\<\>]+$/.test(value);
            }, "不能包含以下符号: $<>");

          
        });
    </script>
</body>
</html>
